<script>
	$(function(){	
		$(".goods-list li").hover(
 				function(){
 				   //当鼠标放上去的时候,程序处理
 				   $(this).addClass("hover1 hover");
 				},
 				function(){
 				   //当鼠标离开的时候,程序处理
 				   $(this).removeClass("hover1 hover");
 				});
 		
 		$('.article-list').find('li').hover(
				function(){
					$(this).css('box-shadow','0px 2px 8px 3px #ccc');
				},
				function(){
					$(this).css('box-shadow','');
				}
			
		);
 		$('#header-search').click(function(){
 			var search = $('.navbar-search');
 			if(search.css('display')=='block'){
 				$('.big-bg').hide();
 	 			$('.navbar-search').hide();
 			}else{
 				$('.navbar-search').show();
 	 			$('.big-bg').show();
 			}
 			
 		});
 		$('.big-bg').click(function(){
 			$('.big-bg').hide();
 			$('.navbar-search').hide();
 		});
 		$('.glyphicon-heart').click(function(){
			 id = $(this).attr('data-id');
			 that = $(this);
			 $.get("{:U('Article/favor')}",{'id':id},function(json){
	            showmsg(json.info);
	            if(json.status == 1){
	            	that.css('color','red');	
	            }else{
	            	that.css('color','red');	
	            }
	  	  	});  
		});
 		$('.icon-like').click(function(){
			 id = $(this).attr('data-id');
			 that = $(this);
			 $.get("{:U('Article/favor')}",{'id':id},function(json){
	            showmsg(json.info);
	            if(json.status == 1){
	            	that.addClass('like');	
	            }else{
	            	that.removeClass('like');	
	            }
	  	  	});  
		});
		
	});

function favor(goodsid){
    $.get("{:U('ajax/favor')}",{id:goodsid},function(json){
            showmsg(json.info);
    })    
}    
function showmsg(msg){
	$("#tip").remove();
	$tip = $('<div id="tip" style="font-weight:bold;position:fixed;top:240px;left: 50%;z-index:9999;background:rgb(255, 45, 94);padding:8px 10px;border-radius:5px;color:#fff;font-size:14px;">'+msg+'</div>');
    $('body').append($tip);
	$tip.stop(true).css('margin-left', -$tip.outerWidth() / 2).fadeIn(500).delay(2000).fadeOut(500);
}
function heightlight_bottom_nav(url){
	
	$('.bottom-menu').find('a[href^="'+url+'"]').closest('div').addClass('active');  	
}
function updateCart(){
	target = "{:U('Cart/updateCart')}";
	$.post(target).success(function(data){
		if(data.errno == 0){
			$('.cart-number').html(data.count);
		}
	});
}
</script>
<block name="script">
</block>



